package cn.sj.util.exception;

import cn.sj.util.code.ResultEnum;
import lombok.Data;

/**
 * @author asus
 * @version 1.0
 * @description: GuiguException
 * @date 2023/4/18 1:09
 */
@Data
public class OAException extends RuntimeException {

    private Integer code;

    private String msg;

    /**
     * 通过状态码和错误消息创建异常对象
     *
     * @param code
     * @param msg
     */
    public OAException(Integer code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    /**
     * 接收枚举类型对象
     *
     * @param resultCodeEnum
     */
    public OAException(ResultEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
        this.msg = resultCodeEnum.getMessage();
    }

    @Override
    public String toString() {
        return "OAException{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                '}';
    }

}
